package com.ruoyi.system.controller;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.system.domain.UserScore;
import com.ruoyi.system.service.IGradesService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.RatingContent;
import com.ruoyi.system.service.IRatingContentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 题目信息Controller
 * 
 * @author ruoyi
 * @date 2024-11-18
 */
@RestController
@RequestMapping("/system/content")
public class RatingContentController extends BaseController
{
    @Autowired
    private IRatingContentService ratingContentService;

    /**
     * 查询题目信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:content:list')")
    @GetMapping("/list")
    public TableDataInfo list(RatingContent ratingContent)
    {
        startPage();
        List<RatingContent> list = ratingContentService.selectRatingContentList(ratingContent);
        return getDataTable(list);
    }

    /**
     * 导出题目信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:content:export')")
    @Log(title = "题目信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RatingContent ratingContent)
    {
        List<RatingContent> list = ratingContentService.selectRatingContentList(ratingContent);
        ExcelUtil<RatingContent> util = new ExcelUtil<RatingContent>(RatingContent.class);
        util.exportExcel(response, list, "题目信息数据");
    }

    /**
     * 获取题目信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:content:query')")
    @GetMapping(value = "/{contentId}")
    public AjaxResult getInfo(@PathVariable("contentId") Long contentId)
    {
        return success(ratingContentService.selectRatingContentByContentId(contentId));
    }

    /**
     * 新增题目信息
     */
    @PreAuthorize("@ss.hasPermi('system:content:add')")
    @Log(title = "题目信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RatingContent ratingContent)
    {
        return toAjax(ratingContentService.insertRatingContent(ratingContent));
    }

    /**
     * 修改题目信息
     */
    @PreAuthorize("@ss.hasPermi('system:content:edit')")
    @Log(title = "题目信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RatingContent ratingContent)
    {
        return toAjax(ratingContentService.updateRatingContent(ratingContent));
    }

    /**
     * 删除题目信息
     */
    @PreAuthorize("@ss.hasPermi('system:content:remove')")
    @Log(title = "题目信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{contentIds}")
    public AjaxResult remove(@PathVariable Long[] contentIds)
    {
        return toAjax(ratingContentService.deleteRatingContentByContentIds(contentIds));
    }
}
